home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / animatin / animatin.sx next >
Encoding:
Text File  |  1996-05-21  |  1.8 KB  |  62 lines  |  [TEXT/ttxt]

  1. --<<<-
  2. -- Filename: ANIMATIN.SX
  3.  
  4. -- Purpose: To demonstrate how animation works, keeping the 
  5. --     target list unchanged -- that is, without using
  6. --     TargetListAction 
  7.  
  8. -- Specialized Classes: (none)
  9.  
  10. -- Instructions to User: Load this file; it displays a yellow window.
  11. --     Watch the red ball move between three spots, then loop continuously 
  12.  
  13. -- Author: Douglas Kramer
  14.  
  15. ------------------------------------------------------------------------
  16.  
  17. -- Create the yellow window
  18. global myWindow := new Window boundary:(new Rect x2:500 y2:400)
  19. myWindow.fill := new Brush color:yellowColor
  20. myWindow.y := 40
  21. show myWindow
  22.  
  23. -- Create the ActionList and ActionListPlayer
  24. global al := new ActionList
  25. global alp := new ActionListPlayer actionList:al scale:30
  26. alp.authorData := myWindow
  27.  
  28. -- Create a red circle
  29. global myShape := new TwoDShape target:(new Oval x2:80 y2:80)
  30. myShape.fill := new Brush color:redColor
  31. myShape.x := 20
  32. myShape.y := 30
  33. prepend myWindow myShape
  34.  
  35. -- Create an interpolator controller for the window
  36. global myInterp := new Interpolator space:myWindow clock:alp
  37. append myInterp myShape
  38.  
  39. -- Put the interpolator on the target list
  40. alp.targets[1] := myInterp
  41.  
  42. -- Create Interpolate actions and append them to the action list
  43. -- Interpolate from time 0 to 75 ticks
  44. append al (new InterpolateAction targetNum:1 time:0 \
  45.     destPosition:(new Point x:400 y:300) destTime:75)
  46.  
  47. -- Interpolate from time 75 to 125 ticks
  48. append al (new InterpolateAction targetNum:1 time:75 \
  49.     destPosition:(new Point x:400 y:30) destTime:125)
  50.  
  51. -- Interpolate from time 125 to 200 ticks
  52. append al (new InterpolateAction targetNum:1 time:125 \
  53.     destPosition:(new Point x:20 y:30) destTime:200)
  54.  
  55. -- At time 200 jump to time 0
  56. append al (new TimeAction time:200 destTime:0)
  57.  
  58. -- Play the action list player
  59. play alp
  60.  
  61. -- To increase its rate, try: alp.rate := 2
  62.